<?php defined('SYSPATH') or die('No direct script access.');

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/28 15:39
 * Desc: 会员折扣
 */
class Controller_Pc_Api_V2_Member_Discount extends Controller_Pc_Api_V2_Base
{
    // 数据请求结果
    private $result;

    /**
     * 参数验证对象
     * @var Request_Api_V2_Member_Discount
     */
    private $validation;

    /**
     * 服务
     * @var Service_Api_Member_Discount
     */
    private $service;

    public function before()
    {
        parent::before();

        // 验证
        $this->validation = Request_Api_V2_Factory::create('member_discount', $this->request_params);

        // 服务
        $this->service = new Service_Api_Member_Discount();

        // 返回数据
        $this->result = array('status' => true, 'msg' => '操作成功', 'data' => array());
    }

    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }

    public function action_get_discount()
    {
        try {
            $this->validation->get_discount()->check();

            $this->result['data'] = $this->service->get_discount($this->mid, $this->request_params);
        } catch (Exception $e) {
            $this->result['status'] = false;
            $this->result['msg']    = $e->getMessage();
        }
    }


}
